package yiyun

import (
	"time"
)

type YiyunTokenResult struct {
	Code int32 `json:"code"`
	Data YiyunAccessToken `json:"data,omitempty"`
	Message string `json:"message,omitempty"`
	Timestamp Time `json:"timestamp"`

}

type YiyunAccessToken struct {

	AccessToken string `json:"accessToken"`

	RefreshToken string `json:"refreshToken,omitempty"`

	Code string `json:"code,omitempty"`

	RefreshExpiresIn int32 `json:"refreshExpiresIn"`

	ClientId string `json:"clientId,omitempty"`

	Openid string `json:"openid"`

	Tag string `json:"tag,omitempty"`

	Satoken string `json:"saToken,omitempty"`



}
type YiyunUserProfileResult struct {
	Code int32 `json:"code"`
	Data YiyunUserProfile `json:"data,omitempty"`
	Message string `json:"message,omitempty"`
	Timestamp Time `json:"timestamp"`

}
type YiyunUserProfile struct {

	UserId int32 `json:"userId"`

	Account string `json:"account,omitempty"`
	Password string `json:"password,omitempty"`
	LastLoginIp string `json:"lastLoginIp,omitempty"`
	LastLoginTime Time `json:"lastLoginTime,omitempty"`
	LoginCount int `json:"loginCount,omitempty"`
	Createtime string `json:"createtime,omitempty"`
	Enable int `json:"enable,omitempty"`
	UserName string `json:"userName,omitempty"`
	Sex int `json:"sex,omitempty"`
	Phone string `json:"phone,omitempty"`
	Email string `json:"email,omitempty"`
	OpenId string `json:"openId,omitempty"`
}





type Time time.Time

const (
	timeFormart = "2006-01-02 15:04:05"
)

func (t *Time) UnmarshalJSON(data []byte) (err error) {
	now, err := time.ParseInLocation(`"`+timeFormart+`"`, string(data), time.Local)
	*t = Time(now)
	return
}

func (t Time) MarshalJSON() ([]byte, error) {
	b := make([]byte, 0, len(timeFormart)+2)
	b = append(b, '"')
	b = time.Time(t).AppendFormat(b, timeFormart)
	b = append(b, '"')
	return b, nil
}

func (t Time) String() string {
	return time.Time(t).Format(timeFormart)
}